﻿using Mobileterminal;
using Mobileterminal.Common;
using Mobileterminal.Dtos;
using Newtonsoft.Json;
using Sunny.UI;
using System;
using System.Windows.Forms;

namespace WinFormsAppDemo2
{
    public partial class LoginForm : UILoginForm
    {
        public LoginForm()
        {
            InitializeComponent();
        }

        private async void LoginForm_ButtonLoginClick(object sender, EventArgs e)
        {
            var url = $"{EnvConfig.BasicReadApi}/User/Login?name=admin&pass=123456";
            var json = await HttpClientHelper.ClientAsync("get", url);

            var result = JsonConvert.DeserializeObject<Result<UserDto>>(json);

            if (result.Code == 200)
            {
                TokenDto.Token = result.Msg;
                MainForm mainForm = new MainForm();
                mainForm.Tag = UserName;
                this.Hide();
                mainForm.ShowDialog();
            }
            else
            {
                MessageBox.Show("登录失败，请检查用户名和密码！");
            }
        }

        private void lblTitle_Click(object sender, EventArgs e)
        {

        }

        private void uiPanel1_Click(object sender, EventArgs e)
        {

        }

      
    }
}